package day16.晚间练习.tcp的程序练习;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss=new ServerSocket(10001);
        Socket socket = ss.accept();
        InputStream is=socket.getInputStream();
        int b;
        while ((b=is.read())!=-1){
            System.out.println((char)b);
        }
        System.out.println("看看我执行了吗");
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        bw.write("who are you?");
        bw.newLine();
        bw.flush();

        bw.close();
        is.close();
        socket.close();
        ss.close();
    }
}
